<?php

include_once 'inc/global.php';

session_start();
if (!isset($_SESSION['tid']))
    $_SESSION['tid'] = '';

$tid = $_SESSION['tid'];
$tablename = $tables[$tid]['t'];

$id = $_SESSION['id'];
$tablename = 'ats_packageprices';

$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset = ($page - 1) * $rows;
$result = array();

include 'inc/conn.php';

$sql = "select count(*) from $tablename";
$rs = mysql_query($sql);

$row = mysql_fetch_row($rs);
$result["total"] = $row[0];

$sql = "select * from $tablename";
$sql .= " limit $offset,$rows";

$rs = mysql_query($sql);

$items = array();
while ($row = mysql_fetch_object($rs)) {
    array_push($items, $row);
}
$result["rows"] = $items;

echo json_encode($result);
?>